﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Cookie : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Cookie存放在客户端，所以用户名和密码一般不建议用Cookie保存在客户端
        //Response.Cookies:设置Cookie的值
        //Request.Cookies:读取Cookie的值
        if (Request.Cookies["username"] != null)
        {
            Label1.Text = "Cookie的值为：" + Request.Cookies["username"].Value;
        }
        else
        {
            Response.Redirect("~/CookieLogin.aspx");
        }
    }
}